package com.yedean.mall.reactor8;

import java.util.Observable;

/**
 * @author HUAWEI
 */
public class ObserverDemo extends Observable {

    public static void main(String[] args) {
        ObserverDemo observe = new ObserverDemo();
        
        //添加观察者
        observe.addObserver(((o, arg) -> System.out.println("发生了变化")));
        
        
        observe.addObserver(((o, arg) -> System.out.println("手动被观察者通知,准备改变")));
        
        //数据变化
        observe.setChanged();
        
        // 通知
        observe.notifyObservers();
    }
}
